<template>
	<view class="user-order">
		<view class="cu-card article no-card" v-for="(orderItem) in orderList" :key="orderItem.orderId">
			<view class="cu-item shadow">
				<view class="title" style="line-height: 200%;">
					<view class="text-cut">{{orderItem.orderName}}</view>
					<view class="text-cut">{{orderItem.orderDate}}</view>
				</view>
				<view class="content">
					<image :src="orderItem.regionImgs[0]" mode="aspectFill"></image>
					<view class="desc">
						<view class="text-content">
							<view class="info">
								<view class="key">
									浴室名称:
								</view>
								<view class="val">
									{{orderItem.regionName}}
								</view>
							</view>
							<view class="info">
								<view class="key">
									浴室状态:
								</view>
								<view class="val">
									{{orderItem.regionState}}
								</view>
							</view>
							<view class="info">
								<view class="key">
									浴室价格:
								</view>
								<view class="val">
									{{orderItem.regionPrice}}/h
								</view>
							</view>
						</view>
						<view class="tag">
							<view class="cu-tag bg-red light sm round">{{orderItem.orderState|orderStateText}}</view>
						</view>
					</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				orderList: [],
				pullUpOn: true,
				pageIndex: 1,
				limit: 6
			};
		},
		onLoad() {
			this.getOrderList()
		},
		methods: {
			getOrderList() {
				if (!this.pullUpOn) return;
				this.$api.getOrderList({
					page: this.pageIndex,
					limit: this.limit
				}).then((res) => {
					if (res.code) {
						if (this.pageIndex == 1) {
							this.orderList = res.data
						} else {
							this.orderList = this.orderList.concat(res.data)
						}
						this.pageIndex++;
					} else {
						this.pullUpOn = false
					}
				})
			}
		},
		onReachBottom: function() {
			this.getOrderList()
		}
	}
</script>

<style lang="scss">
	.user-order {
		.cu-card {
			border-bottom: 4upx solid #dedede;
		}
		.text-content{
			display: flex;
			flex-direction: column;
			.info{
				display: flex;
				.key{
					color: #b5b5b5;
					font-size: 24upx;
				}
				.val{
					margin-left: 10upx;
				}
			}
		}
		.tag{
			text-align: right;
		}
	}
</style>
